#! c:\\Perl\\bin\\perl.exe w

use strict;
use ADN::XML::OBJtoXML;
use ADN::LIBRARY::SNMP::Info;
use ADN::LIBRARY::SOAP::ClientSOAP;

my $ip = $ARGV[0];
my $Srep = $ARGV[1];
my $param = $ARGV[2];

main();
exit 0;

sub main {
  my ( $result, $Detail, $xml, $nbr, $nom, $i );
  my ( @tab, @prm, @data, @result, @sortie_info );

  @tab = split /\%\!\%\*\%\~\%/smx, $param;
  $nbr = scalar @tab;
  print "NBR : $nbr\n";

  for ( my $i = 0; $i < $nbr; $i++ ) {
    @prm = split /\@\#\@\*\@\~\@/smx, $tab[$i];
  }

  $nbr = scalar @prm;
  print "NBR PRM : $nbr\n";

  if ($nbr != 2) {
    print 'Erreur ARG !!!';
    exit 0;
  }

  print "Arg: $prm[0] ET $prm[1]";

  @data = split /;/smx, $prm[0];

  $Detail = ADN::LIBRARY::SNMP::Info->new();
  @sortie_info = $Detail->start(@data);

  $xml = ADN::XML::OBJtoXML->new();
  $xml->Name($prm[1]);
  $xml->Map($xml);
  $i = 0;
  foreach $result (@sortie_info)
  {
    $nom = "Data$i";
    $xml->$nom($result);
    $i++;
  }

  @result = $xml->Detail($xml);

  print "\nDATA : ";
  print @result;

  ADN::LIBRARY::SOAP::ClientSOAP->new( Proxy => $ip,
						                           Service => $Srep,
						                           Data => \@result );
  return;
}
